home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1993…ch: Other People's Memory / ADC Developer CD (1993-03) (''Other People's Memory'')_iso / Dev.CD Mar 93.iso / Technical Documentation / Localization Information / Documentation Browser / Reference Library Browser / Reference Library Browser / stack_-1.xml < prev   
Encoding:
Extensible Markup Language  |  1991-06-19  |  33.5 KB  |  21 lines

  1. <?xml version="1.0" encoding="utf-8" ?>
  2. <!DOCTYPE stack PUBLIC "-//Apple, Inc.//DTD stack V 2.0//EN" "" >
  3. <stack>
  4.     <name>in</name>
  5.     <id>-1</id>
  6.     <cardCount>2</cardCount>
  7.     <cardID>2935</cardID>
  8.     <listID>4177</listID>
  9.     <cantModify><false /></cantModify>
  10.     <cantDelete><false /></cantDelete>
  11.     <cantAbort><false /></cantAbort>
  12.     <cardSize>
  13.         <width>448</width>
  14.         <height>824</height>
  15.     </cardSize>
  16.     <script>
  17. -- Browser 2.1
  18. -- Copyright ¬© 1990-91 Apple Computer, Inc.
  19.  
  20.  
  21.  
  22. -- Initialize browser
  23. ————————————————————————————————————————————————————————————————————————
  24. on openStack
  25.  
  26. global BrowserInited, BrowserPath, DocumentList, Pegasus
  27.  
  28. set cursor to watch
  29.  
  30. put "Reference Library" into Pegasus
  31.  
  32. if BrowserInited = true then exit openStack
  33.  
  34. -- Check the HC version, size
  35.  
  36. if the long version < 02018000 then
  37. answer "This stack requires the use of HyperCard" ¬¨
  38. && "version 2.0v2 or later."
  39. set lockMessages to true
  40. go home
  41. exit to HyperCard
  42. end if
  43.  
  44. if the heapSpace < 750000 then
  45. answer "HyperCard needs more memory. Please increase the current" ¬¨
  46. && "memory size in HyperCard's info window to at least 1,600K."
  47. set lockMessages to true
  48. go home
  49. exit to HyperCard
  50. end if
  51.  
  52. -- Initialize the browser
  53.  
  54. put value of word 2 to 99999 of long name ¬¨
  55. of this stack into BrowserPath
  56. initBrowser
  57. if DocumentList is empty then openDocument
  58.  
  59. end openStack
  60.  
  61.  
  62.  
  63. -- Shut down the browser
  64. ————————————————————————————————————————————————————————————————————————
  65. on closeStack
  66.  
  67. global DocumentList, BrowserPath
  68.  
  69. if BrowserPath ‚↠value of word 2 to 99999 of long name of this stack ¬¨
  70. then exit closeStack
  71.  
  72. if DocumentList is empty ¬¨
  73. and "search" is not in the stacks ¬¨
  74. and "interfaces browser" is not in the stacks ¬¨
  75. and "help" is not in the stacks then shutDownBrowser
  76.  
  77. end closeStack
  78.  
  79.  
  80.  
  81. -- If the user quits HyperCard and the browser's still inited, shut down
  82. ————————————————————————————————————————————————————————————————————————
  83. on quit
  84. global BrowserInited
  85. if BrowserInited = true then shutDownBrowser
  86. end quit
  87.  
  88.  
  89.  
  90. -- Set a flag when the user quits HyperCard
  91. ————————————————————————————————————————————————————————————————————————
  92. on doMenu theItem
  93.  
  94. global HyperCardIsQuitting
  95.  
  96. put (theItem is "quit hypercard") into HyperCardIsQuitting
  97. pass doMenu
  98.  
  99. end doMenu
  100.  
  101.  
  102.  
  103. -- Initialize the browser
  104. ————————————————————————————————————————————————————————————————————————
  105. on initBrowser
  106.  
  107. global BrowserInited, BrowserPath, BrowserFolder
  108.  
  109. getPreferences
  110. loadDocumentList
  111. loadBookmarks
  112. loadNotesDirectory
  113. findSearch
  114. findInterfaces
  115. installMenus
  116. start using stack BrowserPath
  117. put true into BrowserInited
  118.  
  119. end initBrowser
  120.  
  121.  
  122.  
  123. -- Init globals from preferences
  124. ————————————————————————————————————————————————————————————————————————
  125. on getPreferences
  126.  
  127. global PreferencesFolder, BrowserPath, BrowserFolder, ¬¨
  128. InitialWindowLoc, InterfacesType, Pegasus, ¬¨
  129. InterfacesWindowRect, NoteWindowRect, CurrentDocNum
  130.  
  131. -- Find or create the preferences folder
  132.  
  133. if AUXIsRunning() = True then put item 2 of sysPrefs(empty) ¬¨
  134. & Pegasus && "Stuff/" into PreferencesFolder
  135.  
  136. else put item 2 of sysPrefs(empty) & Pegasus && "Stuff:" ¬¨
  137. into PreferencesFolder
  138.  
  139. if fileExists (PreferencesFolder) = false then
  140. get createFolder(PreferencesFolder)
  141. if it ‚↠0 then exit getPreferences
  142. end if
  143.  
  144. -- Get its contents, set globals with it
  145.  
  146. put PreferencesFolder & "Preferences" into preferencesFile
  147. open file preferencesFile
  148. read from file preferencesFile until "" -- EOF
  149. put it into preferences
  150. close file preferencesFile
  151.  
  152. if BrowserPath is empty then
  153. put line 1 of preferences into BrowserPath
  154. else put true into setDefaults
  155. put pathPrefix(BrowserPath) into BrowserFolder
  156.  
  157. put line 2 of preferences into NoteWindowRect
  158. if NoteWindowRect is empty then
  159. put "20,52,360,252" into NoteWindowRect
  160. put true into setDefaults
  161. end if
  162.  
  163. if setDefaults = true then setPreferences
  164. put zero into CurrentDocNum
  165.  
  166. end getPreferences
  167.  
  168.  
  169.  
  170. -- Write the preferences to the preferences file
  171. ———————————————————————————————————————————————————————————————————————
  172. on setPreferences
  173.  
  174. global PreferencesFolder, BrowserPath, InterfacesType, ¬¨
  175. InterfacesWindowRect, NoteWindowRect
  176.  
  177. put PreferencesFolder & "Preferences" into preferencesFile
  178. open file preferencesFile
  179. get BrowserPath & return & NoteWindowRect
  180. write it to file preferencesFile
  181. close file preferencesFile
  182.  
  183. end setPreferences
  184.  
  185.  
  186.  
  187. -- Get the notes directory
  188. ————————————————————————————————————————————————————————————————————————
  189. on loadNotesDirectory
  190.  
  191. global PreferencesFolder, NotesDirectory
  192.  
  193. put folderContents(PreferencesFolder,"Files") ¬¨
  194. & return into NotesDirectory
  195.  
  196. end loadNotesDirectory
  197.  
  198.  
  199.  
  200. -- Go to the browser
  201. ————————————————————————————————————————————————————————————————————————
  202. on goBrowser
  203.  
  204. global BrowserPath, DocBrowserType
  205.  
  206. set cursor to watch
  207. put (BrowserPath is not in the stacks) into needUpdate
  208. go cd DocBrowserType of stack BrowserPath in new window
  209.  
  210. if the result is not empty then
  211. go stack BrowserPath in new window
  212. else if needUpdate then
  213. updateBrowser true
  214. disable menuItem "open browser" of menu "browser"
  215. end if
  216.  
  217. end goBrowser
  218.  
  219.  
  220.  
  221. -- Open a document stack that's not already open
  222. ————————————————————————————————————————————————————————————————————————
  223. on openDocument docNum
  224.  
  225. global DocumentList
  226.  
  227. if docNum is empty then
  228. put fileName("STAK","Please select a document stack.") into docPath
  229. else put item 1 of line docNum of DocumentList into docPath
  230. set cursor to watch
  231.  
  232. if docPath is empty then exit openDocument
  233. if validDocPath(docPath) = false then exit openDocument
  234. if docPath is in the stacks then
  235. show window truncFile(docPath)
  236. exit openDocument
  237. end if
  238.  
  239. go stack docPath in a new window
  240.  
  241. end openDocument
  242.  
  243.  
  244.  
  245. -- Initialize a document
  246. ————————————————————————————————————————————————————————————————————————
  247. on initDocument docPath
  248.  
  249. global DocumentList, DocumentFolder, DocRefNum, DocBrowserType, ¬¨
  250. DocumentName, DocumentPath, CurrentDocNum
  251.  
  252. -- Store information about the document being inited
  253.  
  254. put docPath into DocumentPath
  255. put pathPrefix(DocumentPath) into DocumentFolder
  256. put truncFile(DocumentPath) into DocumentName
  257. put openBrowserFiles(DocumentFolder) into DocRefNum
  258. get IndeXFCN(iGet,DocRefNum,80,"%S","Document.Info","T")
  259. put line 4 of it into DocBrowserType
  260.  
  261. -- Is this an existing (in the list) or a new document?
  262.  
  263. put (DocumentList is empty) into newDoc
  264. if not newDoc then
  265. findInXCMD DocumentList,DocumentName,1
  266. put item 1 of the result into docNum
  267. put (docNum = 0) into newDoc
  268. end if
  269.  
  270. -- If the doc is not in the doc list, add it to the list and menu;
  271. -- otherwise, just update the list and menu
  272.  
  273. if newDoc then
  274. if DocumentList is empty then -- the list is empty
  275. put "-" after menu "documents"
  276. put 1 into docNum
  277. else -- the list is not empty
  278. put (number of lines in DocumentList) + 1 into docNum
  279. end if
  280. end if
  281.  
  282. -- Add it to the doc list and the doc menu
  283.  
  284. put DocumentPath & "," & DocBrowserType & "," & DocRefNum into docEntry
  285. put "openDocument" && docNum into docMsg
  286.  
  287. if newDoc is true then
  288. put docEntry & return after DocumentList
  289. put DocumentName after menu "documents" with menuMsg docMsg
  290. else
  291. put docEntry into line docNum of DocumentList
  292. put DocumentName into menuItem docNum + 2 of menu "documents" ¬¨
  293. with menuMsg docMsg
  294. end if
  295.  
  296. put docNum into CurrentDocNum
  297. updateDocMenuMarks
  298.  
  299. end initDocument
  300.  
  301.  
  302.  
  303. -- The document's closeStack calls this routine
  304. ————————————————————————————————————————————————————————————————————————
  305. on closeDocument
  306.  
  307. global BrowserPath, DocumentList, DocBrowserType, HyperCardIsQuitting, ¬¨
  308. DocRefNum
  309.  
  310. -- Forget it was ever open
  311.  
  312. set cursor to watch
  313. updateDocMenuMarks false
  314. get indeXFCN(iClose,DocRefNum)
  315. put empty into DocRefNum
  316. put empty into DocBrowserType
  317.  
  318. -- Let the user keep the doc on the menu
  319.  
  320. if HyperCardIsQuitting is true then exit closeDocument
  321.  
  322. if the shiftKey is up then
  323. answer "Keep this document in the menu?" with ¬¨
  324. "Remove it" or "Keep it"
  325. if it is "Keep it" then exit closeDocument
  326. end if
  327.  
  328. -- Remove it from the menu
  329.  
  330. set cursor to watch
  331. put value of word 2 to 99999 of long name of this stack into docPath
  332. put truncFile(docPath) into docName
  333.  
  334. if there is a menu "documents" then
  335. if there is a menuItem docName of menu "documents" then ¬¨
  336. delete menuItem docName of menu "documents"
  337. end if
  338.  
  339. -- Delete the document's entry in the document list
  340.  
  341. if DocumentList is not empty then
  342. findInXCMD DocumentList, docPath, 1
  343. put item 1 of the result into docNum
  344. delete line docNum of DocumentList
  345. end if
  346.  
  347. -- Fix the menu messages
  348.  
  349. if DocumentList is not empty then
  350.  
  351. repeat with d = 1 to number of lines in DocumentList
  352. set menuMsg of menuItem d + 2 of menu "documents" to ¬¨
  353. "openDocument" && d
  354. end repeat
  355.  
  356. -- If no docs left open, delete the divider
  357.  
  358. else
  359. if there is a menu "documents" then
  360. if number of menuItems in menu "documents" = 2 then ¬¨
  361. delete menuItem 2 of menu "documents" -- the dividing line
  362. end if
  363. end if
  364.  
  365. end closeDocument
  366.  
  367.  
  368.  
  369. -- When the last stack is closed, shut down the browser
  370. ————————————————————————————————————————————————————————————————————————
  371. on shutDownBrowser
  372.  
  373. global BrowserInited, BrowserPath, DocRefNum, DocumentList, SearchPath
  374.  
  375. set cursor to watch
  376. lock screen
  377.  
  378. put 0 into CurrentDocNum
  379. if DocRefNum is not empty then get IndeXFCN(iClose,DocRefNum)
  380.  
  381. saveDocumentList
  382. saveBookmarks
  383. setPreferences
  384.  
  385. if there is a menu "browser" then delete menu "browser"
  386. if there is a menu "documents" then delete menu "documents"
  387.  
  388. stop using stack BrowserPath
  389. stop using stack SearchPath
  390. put empty into DocumentList
  391. put empty into BrowserInited
  392.  
  393. end shutDownBrowser
  394.  
  395.  
  396.  
  397. -- Install the menus
  398. ————————————————————————————————————————————————————————————————————————
  399. on installMenus
  400.  
  401. global DocumentList, Bookmarks, SearchInited, InterfacesInited, ¬¨
  402. BrowserPath
  403.  
  404. if "Help" is in menu "Go" then delete menuItem "Help" of menu "Go"
  405. if there is a menu "Font" then delete menu "Font"
  406. if there is a menu "Style" then delete menu "Style"
  407.  
  408. put "Open Browser,-,Print Selected Text,Print Section," ¬¨
  409. & "Print Chapter,-,Open Note,Help" into theItems
  410. put "goBrowser,-,printText theselection,printText section," ¬¨
  411. & "printText chapter,-,openNotes,goHelp" into theMsgs
  412.  
  413. if SearchInited = true then
  414. put ",-,Search...,Prev Match,Next Match" after theItems
  415. put ",-,goSearch,goHit prev,goHit next" after theMsgs
  416. end if
  417.  
  418. if InterfacesInited = true then
  419. put ",-,Interfaces Browser...,Interfaces Lookup..." after theItems
  420. put ",-,goInterfaces browser,goInterfaces lookup" after theMsgs
  421. end if
  422.  
  423. if there is not a menu "browser" then create menu "Browser"
  424. put theItems into menu "browser" with menuMsgs theMsgs
  425.  
  426. set cmdchar of menuItem "open browser" of menu "browser" to "U"
  427. set cmdchar of menuItem "open note" of menu "browser" to "Y"
  428.  
  429. if InterfacesInited = true then
  430. set cmdchar of menuItem "interfaces browser..." of menu "browser" to "I"
  431. set cmdchar of menuItem "interfaces lookup..." of menu "browser" to "K"
  432. end if
  433.  
  434. if SearchInited = true then
  435. set cmdchar of menuItem "search..." of menu "browser" to "\"
  436. set cmdchar of menuItem "prev match" of menu "browser" to "["
  437. set cmdchar of menuItem "next match" of menu "browser" to "]"
  438. disable menuItem "prev match" of menu "browser"
  439. disable menuItem "next match" of menu "browser"
  440. end if
  441.  
  442. if there is not a menu "documents" then create menu "Documents"
  443.  
  444. put "Open a Document..." into menu "documents" ¬¨
  445. with menuMsg "openDocument"
  446.  
  447. -- If there is a current document list, init the menu from it
  448.  
  449. if DocumentList ‚↠empty then
  450. put "-" after menu "documents" -- divider
  451. repeat with d = 1 to number of lines in DocumentList
  452. get item 1 of line d of DocumentList
  453. put "openDocument" && d into theMsg
  454. put truncFile(it) after menu "documents" with menuMsg theMsg
  455. end repeat
  456. end if
  457.  
  458. -- Install the bookmarks menu
  459.  
  460. if there is not a menu "bookmarks" then create menu "Bookmarks"
  461.  
  462. put "Set a Bookmark...,Clear a Bookmark...," ¬¨
  463. & "Clear All Bookmarks..." into theItems
  464. put "setBookmark,clearOneBookmark,clearAllBookmarks" into theMsgs
  465.  
  466. if Bookmarks ‚↠empty then
  467. put ",-" after theItems
  468. put "," after theMsgs
  469. repeat with b = 1 to number of lines in Bookmarks
  470. get item 4 of line b of Bookmarks
  471. put "," & it after theItems
  472. put ",goBookmark" && quote & it & quote after theMsgs
  473. end repeat
  474. end if
  475.  
  476. put theItems into menu "bookmarks" with menuMsgs theMsgs
  477. set cmdchar of menuItem "set a bookmark..." of menu "bookmarks" to ";"
  478.  
  479. enableDocMenus false
  480.  
  481. end installMenus
  482.  
  483.  
  484.  
  485. -- Replace our menus if another stack killed 'em
  486. ———————————————————————————————————————————————————————————————————————
  487. on resumeStack
  488. if there is not a menu "browser" then installMenus
  489. end resumeStack
  490.  
  491.  
  492.  
  493. -- Make the specified document the current document
  494. ———————————————————————————————————————————————————————————————————————
  495. on resumeDocument docPath
  496.  
  497. global DocumentList, DocumentFolder, DocBrowserType, DocRefNum, ¬¨
  498. CurrentDocNum, BrowserPath, DocumentName, DocumentPath, SearchInited
  499.  
  500. set cursor to watch
  501. if there is not a menu "browser" then installMenus
  502.  
  503. if DocumentList is empty then exit resumeDocument -- shouldn't happen
  504. if lockScreen is false then lock screen
  505.  
  506. -- Find the resuming document's entry in the document list
  507.  
  508. findInXCMD DocumentList, docPath, 1
  509. put item 1 of the result into CurrentDocNum
  510. get line CurrentDocNum of DocumentList
  511.  
  512. -- Set up the current document globals
  513.  
  514. put item 1 of it into DocumentPath
  515. put pathPrefix(DocumentPath) into DocumentFolder
  516. put truncFile(DocumentPath) into DocumentName
  517. put item 2 of it into DocBrowserType
  518. put item 3 of it into DocRefNum
  519.  
  520. updateDocMenuMarks
  521. if number of this cd > 1 then enableDocMenus true
  522. if SearchInited then enableSearchMenus
  523.  
  524. end resumeDocument
  525.  
  526.  
  527.  
  528. -- A document stack is going into the background
  529. ———————————————————————————————————————————————————————————————————————
  530. on suspendDocument docName
  531. enableDocMenus false
  532. end suspendDocument
  533.  
  534.  
  535.  
  536. -- Enable/disable those menu items used only by document stacks
  537. ————————————————————————————————————————————————————————————————————————
  538. on enableDocMenus isEnabled
  539.  
  540. global HitCardCount, Bookmarks, SearchInited
  541.  
  542. set enabled of menuItem "print selected text" of menu "browser" to isEnabled
  543. set enabled of menuItem "print section" of menu "browser" to isEnabled
  544. set enabled of menuItem "print chapter" of menu "browser" to isEnabled
  545. set enabled of menuItem "open note" of menu "browser" to isEnabled
  546. set enabled of menuItem "set a bookmark..." of menu "bookmarks" to isEnabled
  547.  
  548. if Bookmarks is empty then
  549. disable menuItem "clear a bookmark..." of menu "bookmarks"
  550. disable menuItem "clear all bookmarks..." of menu "bookmarks"
  551. end if
  552.  
  553. end enableDocMenus
  554.  
  555.  
  556.  
  557. -- Go to the appropriate card in the help stack
  558. ————————————————————————————————————————————————————————————————————————
  559. on goHelp where
  560.  
  561. global BrowserFolder
  562.  
  563. set cursor to busy
  564. lock screen
  565.  
  566. -- The "helpCard" handler in the current card, background or stack
  567. -- tells us where to go
  568.  
  569. if where is empty then
  570. send helpCard to this cd
  571. get the result
  572. end if
  573.  
  574. go cd (it) of stack BrowserFolder & "Support files:Help" ¬¨
  575. in new window
  576.  
  577. if the result is not empty then ¬¨
  578. go stack BrowserFolder & "Support files:Help" in new window
  579.  
  580.  
  581. end goHelp
  582.  
  583.  
  584.  
  585. -- This handler tells the goHelp handler which help stack card to go to
  586. ————————————————————————————————————————————————————————————————————————
  587. on helpCard
  588. return 1
  589. end helpCard
  590.  
  591.  
  592.  
  593. -- Open the search stack
  594. ————————————————————————————————————————————————————————————————————————
  595. on goSearch
  596. global SearchInited, SearchPath
  597. if SearchInited is true then go stack SearchPath in a new window
  598. end goSearch
  599.  
  600.  
  601.  
  602. -- Open the interfaces browser stack
  603. ————————————————————————————————————————————————————————————————————————
  604. on goInterfaces which
  605.  
  606. global InterfacesInited, InterfacesPath
  607.  
  608. set cursor to watch
  609.  
  610. if which is "browser" then
  611. go cd 1 of stack InterfacesPath in a new window
  612.  
  613. else if which is "lookup" then
  614. put the selection into keyWord
  615. go cd 2 of stack InterfacesPath in a new window
  616. if the result is not empty then exit goInterfaces
  617. if keyWord is not empty then
  618. put keyWord into cd fld "keyWord"
  619. lookupKeyword
  620. end if
  621. end if
  622.  
  623. end goInterfaces
  624.  
  625.  
  626.  
  627. -- Open a figure
  628. ————————————————————————————————————————————————————————————————————————
  629. on openFigure figRef
  630.  
  631. global DocumentFolder
  632.  
  633. if there is a window figRef then
  634. show window figRef
  635. exit openFigure
  636. end if
  637.  
  638. put DocumentFolder & "Support files:Figures:" & figRef into figPath
  639.  
  640. if fileExists (figPath) = false then
  641. answer figRef && "is yet to be supplied."
  642. exit openFigure
  643. end if
  644.  
  645. picture figPath,file,zoom,true
  646. get the result
  647. if it contains "not found" then
  648. answer "Sorry, figure" && figRef && "is yet to be supplied."
  649. else if it is not empty then answer it
  650.  
  651. end openFigure
  652.  
  653.  
  654.  
  655. -- Set a bookmark
  656. ———————————————————————————————————————————————————————————————————————
  657. on setBookmark
  658.  
  659. global Bookmarks
  660.  
  661. set cursor to watch
  662.  
  663. -- Limit bookmarks to 60
  664.  
  665. if number of lines in BookmarkNames ‚â• 60 then
  666. answer "Sorry, you can't set more than 60 bookmarks."
  667. exit setBookmark
  668. end if
  669.  
  670. -- Get the path of the current stack and the number of current card
  671.  
  672. put value of word 2 to 99999 of long name of this stack into theStack
  673. put number of this cd into theCard
  674.  
  675. -- If there is text selected, use it for the default name
  676.  
  677. if the selection is empty then
  678. put empty into theChunk
  679. put line 1 of bg fld "title" into theName
  680. else
  681. put the selectedChunk into theChunk
  682. put (word 1 to 99999 of (char 1 to 40 of (line 1 of ¬¨
  683. the selection))) into theName
  684. end if
  685.  
  686. -- If the name's too long, truncate it & tack on an ellipse...
  687.  
  688. if length(theName) ‚â• 40 then
  689. repeat with c = 40 down to 1
  690. if char c of theName = " " then exit repeat
  691. end repeat
  692. put char 1 to c - 1 of theName & "..." into theName
  693. end if
  694.  
  695. -- Delete commas from the name
  696.  
  697. repeat
  698. get offset(",",theName)
  699. if it = 0 then exit repeat
  700. delete char it of theName
  701. end repeat
  702.  
  703. -- Let user modify the bookmark name
  704.  
  705. ask "What do you want to call this bookmark?" with theName
  706. if it is empty then exit setBookmark
  707. set cursor to watch
  708. put it into theName
  709.  
  710. if length(theName) ‚â• 80 then
  711. repeat with c = 80 down to 1
  712. if char c of theName = " " then exit repeat
  713. end repeat
  714. put char 1 to c - 1 of theName & "..." into theName
  715. end if
  716.  
  717. repeat until theName is not in Bookmarks
  718. ask "You already have a bookmark by this name." with theName
  719. if it is empty then exit setBookmark else put it into theName
  720. end repeat
  721. set cursor to watch
  722.  
  723. --  Append it to the bookmarks global & menu
  724.  
  725. put theStack & "," & theCard  & "," & theChunk & "," ¬¨
  726. & theName & return after Bookmarks
  727. saveBookmarks
  728.  
  729. if last menuitem of menu "bookmarks" is "clear all bookmarks..." then ¬¨
  730. put "-" after menu "bookmarks"
  731. put theName after menu "bookmarks" ¬¨
  732. with menuMsg "goBookmark" && quote & theName & quote
  733.  
  734. enable menuItem "Clear a bookmark..." of menu "bookmarks"
  735. enable menuItem "Clear all bookmarks..." of menu "bookmarks"
  736.  
  737. end setBookmark
  738.  
  739.  
  740.  
  741. -- Go to a bookmark
  742. ———————————————————————————————————————————————————————————————————————-
  743. on goBookmark bookmarkName
  744.  
  745. global Bookmarks, BrowserFolder
  746.  
  747. set cursor to watch
  748.  
  749. -- Find the entry in the bookmark global
  750.  
  751. findInXCMD Bookmarks,bookmarkName,1
  752. get line (item 1 of the result) of Bookmarks
  753.  
  754. -- Go to the marked card
  755.  
  756. lock screen
  757. go cd (item 2 of it) of stack (item 1 of it) in a new window
  758.  
  759. --  Hilite the marked text
  760.  
  761. if (item 3 of it) is not empty then
  762. unlock screen
  763. select item 3 of it
  764. end if
  765.  
  766. end goBookmark
  767.  
  768.  
  769.  
  770. -- Clear a bookmark
  771. ———————————————————————————————————————————————————————————————————————-
  772. on clearOneBookmark
  773.  
  774. global Bookmarks
  775.  
  776. -- Put up a dialog box listing the bookmarks, let user delete 'em
  777.  
  778. put Bookmarks into list
  779. set cursor to watch
  780. repeat with n = 1 to number of lines in list
  781. delete item 1 to 3 of line n of list
  782. end repeat
  783.  
  784. get listSelect(1,list,"Clear which bookmark?","Clear", ¬¨
  785. "Cancel","20,20,400,200")
  786. if it is empty then exit clearOneBookmark
  787.  
  788. -- Find it in the list, delete it; remove it from the menu
  789.  
  790. findInXCMD Bookmarks,it,1
  791. put item 1 of the result into b
  792. if b = zero then exit clearOneBookmark
  793. delete line b of Bookmarks
  794. saveBookmarks
  795.  
  796. delete menuItem it of menu "bookmarks"
  797.  
  798. -- If there are no more bookmarks, disable the clear/clear all items
  799.  
  800. if Bookmarks is empty then
  801. delete menuItem "-" of menu "bookmarks"
  802. disable menuItem "clear a bookmark..." of menu "bookmarks"
  803. disable menuItem "clear all bookmarks..." of menu "bookmarks"
  804. end if
  805.  
  806. end clearOneBookmark
  807.  
  808.  
  809.  
  810. -- Clear all bookmarks
  811. ———————————————————————————————————————————————————————————————————————-
  812. on clearAllBookmarks
  813.  
  814. global Bookmarks
  815.  
  816. answer "Clear all bookmarks?" with "OK" or "Cancel"
  817. if it is "Cancel" then exit clearAllBookmarks
  818.  
  819. -- Clear the bookmark list, remove 'em from the menu
  820.  
  821. set cursor to watch
  822. put empty into Bookmarks
  823. saveBookmarks
  824.  
  825. get  (enabled of menuItem "Set a bookmark..."  of menu "bookmarks")
  826.  
  827. put "Set a Bookmark...,Clear a Bookmark...," ¬¨
  828. & "Clear All Bookmarks..." after theItems
  829. put "setBookmark,clearOneBookmark,clearAllBookmarks" after theMsgs
  830. put theItems into menu "bookmarks" with menuMsgs theMsgs
  831. set cmdchar of menuItem "set a bookmark..." of menu "bookmarks" to ";"
  832.  
  833. enableDocMenus it
  834.  
  835. end clearAllBookmarks
  836.  
  837.  
  838.  
  839. -- Load bookmarks from bookmarks file (in Preferences folder)
  840. ———————————————————————————————————————————————————————————————————————
  841. on loadBookmarks
  842.  
  843. global Bookmarks, PreferencesFolder
  844.  
  845. put PreferencesFolder & "Bookmarks" into bookmarksFile
  846. open file bookmarksFile
  847. read from file bookmarksFile until "" -- end of file
  848. close file bookmarksFile
  849. put it into Bookmarks
  850.  
  851. end loadBookmarks
  852.  
  853.  
  854.  
  855. -- Load document list from document list file (in Preferences folder)
  856. ———————————————————————————————————————————————————————————————————————
  857. on loadDocumentList
  858.  
  859. global DocumentList, PreferencesFolder
  860.  
  861. put PreferencesFolder & "Document List" into docListFile
  862. open file docListFile
  863. read from file docListFile until "" -- end of file
  864. close file docListFile
  865. put it into DocumentList
  866.  
  867. -- Delete the docRefNums from the list; they're invalid
  868.  
  869. repeat with d = 1 to number of lines in DocumentList
  870. put empty into item 3 of line d of DocumentList
  871. end repeat
  872.  
  873. end loadDocumentList
  874.  
  875.  
  876.  
  877. -- Save document list (in Preferences folder)
  878. ———————————————————————————————————————————————————————————————————————
  879. on saveDocumentList
  880.  
  881. global DocumentList, PreferencesFolder
  882.  
  883. put PreferencesFolder & "Document List" into docListFile
  884. open file docListFile
  885. write DocumentList to file docListFile
  886. close file docListFile
  887.  
  888. end saveDocumentList
  889.  
  890.  
  891.  
  892. -- Save bookmarks to bookmarks file (in Preferences folder)
  893. ———————————————————————————————————————————————————————————————————————
  894. on saveBookmarks
  895.  
  896. global Bookmarks, PreferencesFolder
  897.  
  898. put PreferencesFolder & "Bookmarks" into bookmarksFile
  899. open file bookmarksFile
  900. write Bookmarks to file bookmarksFile
  901. close file bookmarksFile
  902.  
  903. end saveBookmarks
  904.  
  905.  
  906.  
  907. -- Open a note
  908. ———————————————————————————————————————————————————————————————————————
  909. on openNotes
  910.  
  911. global PreferencesFolder, NotesDirectory, NoteFilePath, ¬¨
  912. NoteWindowRect, NoteText
  913.  
  914. set cursor to watch
  915.  
  916. if there is a window "Note" then
  917. send "select" to window "Note"
  918. exit openNotes
  919. end if
  920.  
  921. -- Build the note file name using the stack name and card #
  922.  
  923. put "Note" && number of this cd && "(" ¬¨
  924. & char 1 to 18 of short name of this stack & ")" into noteFile
  925. put PreferencesFolder & noteFile into NoteFilePath
  926.  
  927. lock screen
  928. put empty into NoteText
  929.  
  930. -- If it card # in NotesDirectory, get the content of the note file
  931.  
  932. if noteFile is in NotesDirectory then
  933. open file NoteFilePath
  934. read from file NoteFilePath until "" -- end of file
  935. close file NoteFilePath
  936. put it into NoteText
  937. end if
  938.  
  939. -- Open the window. TEXWindow params are: window name, text,
  940. -- rect (items), font, size, lineHeight, wrap width in pixels
  941.  
  942. TEXWindow "Note", NoteText ,¬¨
  943. item 1 of NoteWindowRect, item 2 of NoteWindowRect, ¬¨
  944. item 3 of NoteWindowRect, item 4 of NoteWindowRect, ¬¨
  945. "geneva", "10","14",item 3 of NoteWindowRect ¬¨
  946. - item 1 of NoteWindowRect - 20
  947.  
  948. end openNotes
  949.  
  950.  
  951.  
  952. -- The text window's been closed
  953. ________________________________________________________________________
  954. on TEXWindowClosing windowName, isDirty
  955.  
  956. global NoteWindowRect, NoteText
  957.  
  958. -- Get the current text and record the window rect
  959.  
  960. put text of window "Note" into newNoteText
  961. put the globalRect of window "Note" into NoteWindowRect
  962. setPreferences
  963.  
  964. -- Did the user change the text in the note window?
  965.  
  966. if newNoteText = NoteText then return true -- close the window
  967.  
  968. if newNoteText is empty then
  969. answer "Delete this note?" with "Cancel" or "Delete"
  970. if it is "Cancel"then
  971. return true
  972. end if
  973. else
  974. answer "Save changes to note?" with "Cancel" or "Discard" or "Save"
  975. if it is "discard" then return true -- close the window
  976. else if it is "cancel" then return false -- leave the window open
  977. end if
  978.  
  979. -- The user hit the "Save" button
  980.  
  981. updateNotes newNoteText
  982. return true -- close the window
  983.  
  984. end TEXWindowClosing
  985.  
  986.  
  987.  
  988. -- Update the note file for this card, and the notes directory
  989. ________________________________________________________________________
  990. on updateNotes newNoteText
  991.  
  992. global PreferencesFolder, NotesDirectory, NoteText, NoteFilePath
  993.  
  994. -- If the notes are empty, delete the note file and hide the note
  995. -- button; otherwise, save the notes and show the note button
  996.  
  997. if newNoteText = empty then
  998. deleteFile NoteFilePath
  999. hide bg btn "showNotes"
  1000. else
  1001. open file NoteFilePath
  1002. write newNoteText to file NoteFilePath
  1003. close file NoteFilePath
  1004. show bg btn "showNotes"
  1005. end if
  1006.  
  1007. -- Update the notes directory
  1008.  
  1009. put newNoteText into NoteText
  1010. put folderContents(PreferencesFolder,"Files") ¬¨
  1011. & return into NotesDirectory
  1012.  
  1013. end updateNotes
  1014.  
  1015.  
  1016.  
  1017. -- Print selection, section or chapter
  1018. ———————————————————————————————————————————————————————————————————————
  1019. on printText which
  1020.  
  1021. if which is "theselection" then
  1022. if the selection is empty then
  1023. answer "There is no text selected."
  1024. else
  1025. set printTextFont to monaco
  1026. set printTextSize to 9
  1027. set printTextHeight to 12
  1028. print the selection
  1029. end if
  1030.  
  1031. else if which is "section" then
  1032. open report printing with template "full page"
  1033. print this cd
  1034. close printing
  1035.  
  1036. else if which is "chapter" then
  1037. set cursor to watch
  1038. lock screen
  1039. push cd
  1040. repeat until bg fld "chapterDisplay" ‚↠bg fld "chapterDisplay" ¬¨
  1041. of prev cd
  1042. go prev cd
  1043. end repeat
  1044. open report printing with template "full page"
  1045. repeat
  1046. print this cd
  1047. if bg fld "chapterDisplay" ‚↠bg fld "chapterDisplay" of ¬¨
  1048. next cd then exit repeat
  1049. go next cd
  1050. end repeat
  1051. close printing
  1052. pop cd
  1053. end if
  1054.  
  1055. end printText
  1056.  
  1057.  
  1058.  
  1059. -- Update the checkmarks on the document menu
  1060. ———————————————————————————————————————————————————————————————————————
  1061. on updateDocMenuMarks which
  1062.  
  1063. global DocumentList, CurrentDocNum
  1064.  
  1065. repeat with d = 1 to number of lines in DocumentList
  1066. if which is not empty then
  1067. set the checkMark of menuItem d + 2 of menu "documents" to which
  1068. else set the checkMark of menuItem d + 2 of menu "documents" to (d = CurrentDocNum)
  1069. end repeat
  1070.  
  1071. end updateDocMenuMarks
  1072.  
  1073.  
  1074.  
  1075. -- Open the browser TOC files for a given document folder
  1076. ———————————————————————————————————————————————————————————————————————-
  1077. function openBrowserFiles docFolder
  1078.  
  1079. put docFolder & "Support files:Browser.i" into tocIndex
  1080. put docFolder & "Support files:Browser.d" into tocData
  1081.  
  1082. get IndeXFCN(iOpen,tocIndex,true,false,tocData)
  1083. if word 1 of it = 0 then return word 2 of it
  1084. else
  1085. answer "Couldn't open the table of contents files." ¬¨
  1086. && "The files ‚Äúbrowser.i‚Äù and ‚Äúbrowser.d‚Äù must be in the" ¬¨
  1087. && "document's ‚ÄúSupport files‚Äù folder."
  1088. return empty
  1089. end if
  1090.  
  1091. end openBrowserFiles
  1092.  
  1093.  
  1094.  
  1095. -- Find and init the search stack
  1096. ———————————————————————————————————————————————————————————————————————-
  1097. on findSearch
  1098.  
  1099. global BrowserFolder
  1100.  
  1101. get BrowserFolder & "Support files:Search"
  1102. if there is a file it then
  1103. start using stack it
  1104. initSearch it -- in the search stack
  1105. end if
  1106.  
  1107. end findSearch
  1108.  
  1109.  
  1110.  
  1111. -- Find and initialize the interfaces browser stack
  1112. ———————————————————————————————————————————————————————————————————————-
  1113. on findInterfaces
  1114.  
  1115. global BrowserFolder
  1116.  
  1117. get BrowserFolder & "Support files:Interfaces:Interfaces Browser"
  1118. if there is a file it then
  1119. start using stack it
  1120. initInterfaces it -- in the interfaces stack
  1121. end if
  1122.  
  1123. end findInterfaces
  1124.  
  1125.  
  1126.  
  1127. -- Commas, parens & hypens in file names will screw various things up
  1128. ———————————————————————————————————————————————————————————————————————-
  1129. function validDocPath docPath
  1130.  
  1131. if (docPath contains ",") or (docPath contains "(") or ¬¨
  1132. (docPath contains "-") then
  1133. answer "Document names cannot contain commas, parentheses" ¬¨
  1134. && "or dashes."
  1135. return false
  1136. else return true
  1137.  
  1138. end validDocPath</script>
  1139.     <background id="2796" file="background_2796.xml" name="" />
  1140.     <card id="2935" file="card_2935.xml" marked="false" name="" owner="2796" />
  1141.     <card id="4060" file="card_4060.xml" marked="false" name="standardDocument" owner="2796" />
  1142. </stack>
  1143.